﻿// JavaScript Document
function valida()
	{var msg;
		var cont;
		cont = 0;
		msg = "";
		if (document.form.txtNombre.value == '')
			{msg = msg + "El nombre es un campo requerido\n";cont=1;}
		if (document.form.txtUsuario.value == '')
			{msg = msg + "El usuario es un campo requerido\n";cont=1;}
		if (document.form.txtClave.value == '')
			{msg = msg + "La contraseña es un campo requerido\n";cont=1;}
		
		if (cont == 1)
			{alert(msg);return false;}
		else
			{	//document.form.submit();
                                updateAndValAccount();
				return true;
			}
	}

function valida_add()
	{var msg;
		var cont;
		cont = 0;
		msg = "";
		if (document.frmAddUsrUsmi.txtResponsable.value == '')
			{msg = msg + "El nombre es un campo requerido\n";cont=1;}
		if (document.frmAddUsrUsmi.txtUsr.value == '')
			{msg = msg + "El usuario es un campo requerido\n";cont=1;}
		if (document.frmAddUsrUsmi.txtPassword.value == '')
			{msg = msg + "La contraseña es un campo requerido\n";cont=1;}
		
		if (cont == 1)
			{alert(msg);return false;}
		else
			{saveAndValAccount();
				//document.frmAddUsrUsmi.submit();
				return true;
			}
	}

function checklength()
{
    var max = 255;
    var txt;
    txt=document.getElementById('nwAviso');
    var n = txt.value.length;
    if (n>max) //i is the maxlength of textarea which we have set to 80
    {
        txt.value = txt.value.substring(0, max);
        return false;
    }
}

function actdesa(id,div,pagina)
{
    var id_aviso="";
    var accion="";
    var status="";
    accion= document.getElementById(id).value;
    status= document.getElementById(id).checked;

    if(status==true)
    {
      status=1;
    }else{
        status=0;
    }

    $(div).style.display = "block";
    	var x = Math.random()*1000;
	x = Math.round(x);
	$(div).innerHTML = "<center><img src='../images/aero_busy_xl.gif' border='0'></img>&nbsp;<strong>Cargando...</strong></center>";

        new Ajax.Updater(div, pagina,
	{
		method: 'post',
		parameters: {idaviso:id.substr(2,2),opcion:accion,status:status},
                serialize:true,
		evalScripts:true
	}
          );

}